package CLI;


import command.*;
import object.Branch;


public class Main {
    public static void main(String[] args) throws Exception{
        if(args.length < 1 || args[0].equals("help")) {
            HelpCommand help = new HelpCommand();
            help.excute();
        }else {
            if(args[0].equals("init")) {
                InitCommand init = new InitCommand();
                init.excute();
            }
            else if(args[0].equals("add")) {
                AddCommand add = new AddCommand(args[1]);
                add.excute();
            }
            else if(args[0].equals("commit")) {
                CommitCommand commit = new CommitCommand(args[1]);
                commit.excute();
            }

            else if(args[0].equals("rm")) {
                RmCommand rm = new RmCommand(args[1]);
                rm.excute();
            }
            else if(args[0].equals("ls-file")){
                LsFileCommand lsFile;
                if(args.length >2) {
                    lsFile = new LsFileCommand(args[1], args[2]);
                }
                else{
                    lsFile = new LsFileCommand(args[1]);
                }
                lsFile.excute();
            }
            else if(args[0].equals("log")){
                LogCommand log = new LogCommand();
                log.excute();
            }
            else if(args[0].equals("branch")){
                BranchCommand branch= new BranchCommand(args[1]);
                branch.excute();
            }
            else if(args[0].equals("checkout")){
                CheckoutCommand checkout = new CheckoutCommand(args[1]);
                checkout.excute();
            }
            else {
                System.out.println("jit: " + args[1] + "is not a valid command. See 'jit help'.");
            }
        }
    }
}